/**
 * @author ZhiWen Ren
 * @version 1.0
 * @description: LeetCode-55-跳跃游戏
 * @date 2025/7/19 14:58
 */
public class Solution55 {
    public boolean canJump(int[] nums) {
        int n = nums.length;
        int farthestPos = 0;
        for (int i = 0; i < n; i++) {
            if (i <= farthestPos) {
                farthestPos = Math.max(farthestPos, i + nums[i]);
                if (farthestPos >= n - 1) return true;
            }
        }
        return false;
    }
}
